package com.wdh.monitor.cfg;

import com.wdh.monitor.base.MonitorHandler;
import com.wdh.monitor.base.MonitorProducer;
import com.wdh.monitor.service.MonitorMongoService;
import lombok.AllArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@AllArgsConstructor
@EnableConfigurationProperties(MongoProperties.class)
public class MonitorMongoServiceAutoCfg {

    private MongoProperties mongoProperties;

    @Bean
    public MonitorMongoService monitorMongoService(MongoProperties mongoProperties){
        return new MonitorMongoService(mongoProperties);
    }

    @Bean
    public MonitorHandler monitorHandler(MonitorMongoService monitorMongoService){
        return new MonitorHandler(monitorMongoService);
    }

    @Bean
    public MonitorProducer monitorPruducer(MonitorHandler monitorHandler){
        return new MonitorProducer(monitorHandler);
    }
}
